home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 16 / pcfolded.zip / FOLDED.DOC next >
Text File  |  1989-05-30  |  39KB  |  724 lines

  1.                 FOLDED
  2.                A folding editor
  3.               (c) 1989
  4.             By Todd Burkey
  5.  
  6. 1.0 GENERAL:
  7.  
  8.   FOLDED is a dual mode editor that provides several advanced features
  9.   not currently found in text and programming editors. FOLDED is primarily
  10.   intended to be used as a source code editor. As such, it incorporates
  11.   a folding feature similar to that found in thought processor programs
  12.   but with added support for the C language (and eventually Pascal). FOLDED
  13.   also has some relational capabilities. These allow the user to associate
  14.   lines in their source files with sections of their documentation files
  15.   and vice-versa. And both folding and relations are incorporated in such a
  16.   fashion that they don't impact the original text files in any way.
  17.  
  18.  
  19. 2.0 FEATURES:
  20.  
  21.   FOLDED also has the standard set of editor features, with a few bells and
  22.   whistles thrown in. It has dynamic 'as-you-type' searching, substitution by
  23.   block/global/direction of a string or exact word match (i.e. change
  24.   variable i to i_var throughout your code), block copy/move/kill in normal
  25.   or rectangular region modes, marks that allow intra-buffer movement, easy
  26.   movement between buffers, a trash can, variable skipping (point to a
  27.   variable, press ^n to skip to the next occurrence of it, ^p for previous),
  28.   configuration save (you can leave a multi-buffer edit session and come
  29.   back to the exact place you left off with all buffer positions restored),
  30.   built in help, prompting for the beginning user, one-key buffer cloning,
  31.   and more.
  32.  
  33. 3.0 LIMITATIONS:
  34.  
  35.   So what doesn't FOLDED do? Well, the first release will not have an UNDO
  36.   feature. The trash can will have to do. It also is dual mode, something
  37.   which may alienate some of the Emacs users out there (I am bi-editable,
  38.   since I use Emacs on some systems, graphic shell editors on others, vi
  39.   on still others). With a little work, the editor could actually be made
  40.   to work either as a dual mode editor or a single mode editor (hint to
  41.   hackers out there). It also could use some better screen optimization,
  42.   since I tended to develop it on high speed displays. It is usable at
  43.   2400 baud, but any slower than that and you are better off with ed.
  44.   The first release also won't have any key binding capability. I still
  45.   haven't decided upon the best approach to handle user-defined key maps.
  46.   Finally, FOLDED isn't a layered editor. My goals during the development
  47.   of FOLDED were to keep it relatively small (it is about 70K executable,
  48.   <6000 lines of source) and fast, so layering as implemented in emacs-like
  49.   editors was out.
  50.  
  51. 4.0 HISTORY:
  52.  
  53.   I wrote FOLDED simply to learn.  Early on, I made a choice to 1) put
  54.   basic 'must-have' functionality in the editor, 2) put advanced concepts
  55.   into the editor that can't be handled by external programs (folding and
  56.   relational features), 3) implement a simple to use and understand multi
  57.   file editing capability so that moving between files and scratchpads
  58.   was easy, 4) design the editor so that I could add enhanced 'wish-list'
  59.   functionality as I determined I needed it, 5) ensure that the final
  60.   version of the editor would function the same on my Atari ST at home as
  61.   it does on the Sun or Apollo workstations and even as it does on the
  62.   mainframes, and 6) keep the program small (I hate long loading times).
  63.   The latter requirement somewhat dictates the earlier ones...at least
  64.   for the first release.
  65.  
  66.   Having used many editors over the last 15 years, I decided to implement
  67.   (or try to anyway) the features I liked most in the various editors. This
  68.   decision steered me away from any thoughts of modifying an existing editor
  69.   like emacs or vi, hence I diverged from the 'standard' a bit. First, FOLDED
  70.   is an unconstrained editor. You can move your cursor anywhere on the screen
  71.   and when you enter insert mode (or copy a rectangular block of text) FOLDED
  72.   will take care of sticking in needed spaces. Another difference is that the
  73.   editor does not 'wrap' lines. Instead, you can scroll/page the entire window
  74.   sideways when necessary (the editor will do this for you if you are typing
  75.   past the end of the right margin). I got too used to this feature on the
  76.   Apollos, I guess. Also, FOLDED does not retain tab characters. Rather, they
  77.   are replaced with white space on input and FOLDED will optionally 'optimize'
  78.   your file when you write it out (i.e. inserting tabs wherever it can, removing
  79.   trailing spaces on lines, etc). Actually, FOLDED doesn't even retain leading
  80.   spaces in the way you might expect an editor to store them. All leading spaces
  81.   in a line are compressed to an integer variable upon file read-in. The user
  82.   still sees the spaces on the screen, but internally this sped up my folding
  83.   logic (at the cost of almost going insane over the added code complexity...
  84.   there is always a tradeoff).
  85.  
  86. 5.0 COMPATIBILITY:
  87.  
  88.   The first release of FOLDED has been tested on BSD4.2/3 (Suns, Symetric,
  89.   and Apollo), SYSVR3 (ETA-10...haha), the IBM PC, and the ATARI ST. It is
  90.   being ported by others to the Mac. A preliminary port of the code to the
  91.   BELLCORE MGR (window manager) environment took only two hours on a Sun
  92.   workstation and provided individual windows for each buffer (with
  93.   title bars).
  94.  
  95.  
  96. 6.0 EDITING COMMANDS:
  97.  
  98.   When you invoke FOLDED the first time, press the ? key to see a cheat sheet
  99.   that tells you what each key does.  The following section covers the FOLDED
  100.   commands in more detail. Note that whenever you are prompted for something
  101.   in FOLDED, you will see the default response inside of brackets. Pressing
  102.   the Return key will select this response. Also, in most cases, pressing
  103.   the ESC key will return you to the top level command mode of FOLDED. It is
  104.   important to remember that FOLDED is a DUAL mode editor. You start out in
  105.   command mode and must use one of the insert commands to actually add text
  106.   to the file you are editing. While in insert mode, you will continually be
  107.   informed of this fact by a status line on the bottom of the screen.
  108.  
  109. 6.1 REPETITION:
  110.   Sometimes, you will wish to execute a command more than once. To do so,
  111.   press the number keys to indicate the number of times you wish to do
  112.   something and then do it. For example, if you wish to move down 4 pages,
  113.   press 4J or if you wish to delete 8 characters, press 8d. Currently,
  114.   only the movement and character delete commands utilize the feature.
  115.  
  116. 6.2 MOVEMENT:
  117.   The standard 'rogue' keys are used for single character cursor movement :-).
  118.   Thus, the 'k' key will move you up one character, the 'j' key will move
  119.   you down one character, the 'h' key moves you left one character, and the
  120.   'l' key moves you right one character. As a natural extension of this, I
  121.   chose to have the 'K', 'J', 'H', and 'L' keys move you farther in the same
  122.   directions. For example, 'K' and 'J' will page you up and down, while the
  123.   'H' and 'L' keys will move you 20 characters to the left or right.  If you
  124.   are using an ATARI ST, then the arrow keys also function for cursor movement.
  125.  
  126.   You can also go to the beginning of a line by pressing the '^' key and
  127.   go to the end of a line by pressing the '$' key. To go to a specific
  128.   line number, just press the 'g' key and you will be prompted for the
  129.   line number you wish to go to. For those of you who prefer the jump-page
  130.   technique over scrolling, you can toggle between the two modes by pressing
  131.   the 'p' key.
  132.  
  133. 6.3 READING:
  134.   FOLDED allows you to read files in a variety of ways. The standard way is to
  135.   simply invoke FOLDED with a list of files to edit. When you are in FOLDED,
  136.   you can read a file into a new buffer by using the ':r' keys. If you wish
  137.   to view a file (i.e. not be able to edit it), then use the ':v' keys. And,
  138.   if you wish to insert a file into the current buffer, then use the ':i' keys.
  139.   In each case, you will be prompted for the file name you wish to read in.
  140.   Another way of reading files is to simply position the cursor over a file
  141.   name and press '^r' (Control-r). Likewise, you can press '^v' if you just
  142.   want to view the file.
  143.  
  144.   Another way files are read in by FOLDED is 'on-demand'. This method is
  145.   used by the relation commands to pull a file in if you request FOLDED to
  146.   go to a related line and the necessary file isn't already read in. It is
  147.   also used by the '-c' option when you invoke FOLDED to read all the files
  148.   back in that you were editing when you last 'saved' a session. In both
  149.   cases, FOLDED will place you at the correct position in the buffer.
  150.  
  151. 6.4 WRITING:
  152.   Writing files in FOLDED is a bit less complicated. To write out the current
  153.   buffer, press the ':w' keys. If you happen to be in a 'blok'ed off region, you
  154.   will be asked if you just want to save that region to a file. Then you are
  155.   prompted for a file name. After entering the file name, you can optionally
  156.   be prompted as to whether you wish to optimize the output text or not. If you
  157.   choose to optimize, then tabs are inserted in the text wherever practical and
  158.   tailing spaces on lines are stripped off. If not, then NO tabs will appear in
  159.   the output text at all.
  160.  
  161.   Another way of saving files is to press the ':s' keys. This will 1) save a
  162.   configurations file of which files you are currently editing (and where you
  163.   are in each buffer), and 2) cycle through all edited files asking if you
  164.   wish to save them.
  165.  
  166. 6.5 INFO:
  167.   A help cheat-sheet is available in FOLDED by pressing the '?' key from
  168.   the top level command mode. If you aren't sure what is going on and '?'
  169.   doesn't give you the help screen, then press the ESC key followed by the
  170.   '?' key.
  171.  
  172.   If you want to know where you are in a file, or even which file you are
  173.   currently editing, press the '=' key. You will see a highlighted line
  174.   appear on the same line your cursor was on with the line and column number
  175.   you are on relative to the file you are editing, the screen coordinates you
  176.   are on, and the file name. Pressing the '=' key again will revert your line
  177.   back to normal.
  178.  
  179.   One final type of information is available by pressing the 'X' key. This
  180.   will display a full screen of info showing all the files you are currently
  181.   editing, the number of lines, where you are in the file, part of the text
  182.   in the line you are 'on' in the file, etc.
  183.  
  184. 6.6 SEARCHES:
  185.   Searching is an important part of using an editor from a programmers'
  186.   viewpoint. It needs to be fast and consequentially involve as little typing
  187.   as possible. To this end, I implemented two distinct types of searching in
  188.   FOLDED. These are dynamic searching and word searching.
  189.  
  190.   Dynamic searching is similar to that used in many of the micro-emacs
  191.   implementations. By pressing the '/' key in FOLDED, you will be prompted
  192.   for what you wish to search for. As you type, FOLDED will search for what
  193.   you are typing, moving you visibly to the line you are searching for and
  194.   warning you when you have typed something that doesn't match. As you are
  195.   searching in this fashion, the Backspace key will cycle you back to where
  196.   the appropriate matches were found originally. Also the '^n' and '^p' keys
  197.   will find the next or previous occurrences of the string you last found.
  198.   The ESC key must be used to exit this mode of searching. Note that using
  199.   the '/' key provides forward search capability and the '\' key provides
  200.   backwards search capability. Also, when you press the '/' or '\' keys, you
  201.   will see the last thing you searched for inside brackets. Pressing the
  202.   return key when you see this will continue your search for the same text.
  203.   This becomes very handy when you are searching multiple buffers for a
  204.   string.
  205.  
  206.   Word searching is even easier. You just position you cursor over a word
  207.   and press '^n' or '^p' to find the next or previous occurrence of the word.
  208.   By default, the search is inclusive, so FOLDED will look for the next
  209.   string that contains the word. If you press the '^e' key sequence before
  210.   doing your searches, EXACTMODE searching will be enabled. This simply means
  211.   that only exact word matches will be used during word searches. This turns
  212.   out to be handy if you are checking to see where variable 'i' is used
  213.   throughout a procedure. Pressing '^e' a second time turns off exact mode
  214.   (it is a toggle).
  215.  
  216.   Note: Searching in FOLDED currently doesn't support any regular expression
  217.   parsing. I thought I would miss this, since I find it mandatory in VI and
  218.   EMACS, but so far I haven't needed it enough to bother sticking the code in
  219.   (I did work out some of the logic to do the most common VI/EMACS REGEXP
  220.   options).
  221.  
  222. 6.7 BUFFERS:
  223.   A number of commands allow movement between buffers. Direct selection of a
  224.   new buffer is made using: 1) the space bar to cycle through the buffers
  225.   one at a time, 2) the '^g' key sequence to allow you to go to a buffer
  226.   directly (more on this later), 3) the 't' key to toggle back and forth
  227.   between two buffers, and 4) the 'T' key to toggle back and forth between
  228.   a buffer and the trash can. Whenever you go to a buffer using these methods,
  229.   the screen will be repainted with the contents of the destination buffer
  230.   and the name of the buffer will be displayed at the bottom of the screen.
  231.   Using '^g' will allow you to cycle through the list of buffers at the bottom
  232.   of the screen using the 'j' and 'k' keys to scroll and the Return key to
  233.   select. If you forget how to do this, press the '?' key after pressing '^g'
  234.   and you will get some help.
  235.  
  236.   Indirect selection of a buffer is made when you 'goto' a relation and FOLDED
  237.   automatically moves you to a new buffer, or as mentioned earlier, when you
  238.   read in a new file. Another way you can end up in a new buffer is by pressing
  239.   the 'c' key. This will create an empty (scratch) buffer and place you in it.
  240.   Pressing the 'C' key will make a complete copy (clone) of your current buffer
  241.   into a new one and place you in it. Finally, using the '-k' key sequence will
  242.   allow you to kill your current buffer (you will be prompted for verification
  243.   before FOLDED does so), and then you will be moved to a previous buffer. Note
  244.   that 'killing' the Trash Can simply empties it and leaves you sitting in the
  245.   Trash Can buffer.
  246.  
  247.   Several comments are appropriate here about the Trash Can buffer. Every
  248.   line you delete or multiple character sequence you delete will be moved
  249.   to this buffer. Obviously, when you delete things from the trash can, they
  250.   are really, truly gone. The Trash Can can be used as a scratch pad. In fact,
  251.   the 'y' key will automatically insert the last line your cursor was
  252.   positioned on in the trash can directly into your current line in another
  253.   buffer. This is kind of like having an editable cut and paste buffer. Note
  254.   that the Trash Can isn't automatically saved out by FOLDED, but it can
  255.   be written out using ':w'.
  256.  
  257. 6.8 BLOCKS:
  258.   You can do things with regions of text in FOLDED using the 'blok' option
  259.   key ('b'). Selecting this key will present you with the following prompt:
  260.  
  261.   blok-? (Start, End, Box, Norm, Move, Copy, Kill, Unset, Fold, Line <ESC>)
  262.  
  263.   Where the options are defined as follows:
  264.       -Start  = current cursor position defines start of block
  265.       -End    = current cursor position defines end of block
  266.       -Box    = rectangular cut and paste region
  267.       -Normal = normal cut/paste region
  268.       -Move   = move block in buffer somewhere else
  269.       -Copy   = copy block in buffer somewhere else
  270.       -Kill   = move block to the trash can
  271.       -Unset  = undefines a block
  272.       -Fold   = fold a block
  273.       -Line   = block the current line
  274.       -ESC    = The escape key aborts the blok option command
  275.   If you select the Move or Copy operations, FOLDED will further prompt you
  276.   about where you wish to move the current buffers block to. The prompt you
  277.   will see will be:
  278.  
  279.   To which buffer (c-current, t-tagged, s-select one) [ESC] ?
  280.  
  281.   Again, the ESC key will abort the blok option command. The 'c' key will
  282.   simply copy the block into the same buffer at the cursor position. The
  283.   't' key will copy the block into the buffer most recently tagged with the
  284.   '^b' key (tag buffer key). Finally, the 's' key will put you into the
  285.   same type of selector window that the '^g' key uses to select a buffer
  286.   to go to.
  287.  
  288.   In all of these cases, when you are pushing a block of text to another
  289.   buffer, the block will be inserted in the destination buffer immediately
  290.   following the line that you were last on in that buffer (or in the line
  291.   after the cursor if you are doing a box region copy/move). This method
  292.   was implemented to ease the 'building' of code fragments from a number
  293.   of other buffers (i.e. you are editing a file and realize you need a small
  294.   code fragment from another file, so you press '^b' to mark you current
  295.   buffer as the tagged buffer for copies, press ':r' and enter the other
  296.   file name, find the text you want using the '/' key, use the 'bs' and 'be'
  297.   keys to define the start and end of the block, press the 'bct' keys to do
  298.   a block copy to the tagged buffer, and then press the 't' key to move back
  299.   to where you were before you started.)
  300.  
  301. 6.9 CHANGING:
  302.   Two mechanisms exist for changing (substituting) text using FOLDED. First,
  303.   the 's' key can be used to simply replace a single character. Just move the
  304.   cursor over the character you wish to change, press the 's' key, FOLDED will
  305.   prompt you for the new character, press it, and you are done. If you want to
  306.   perform string or word substitutions, press the 'S' key. FOLDED will prompt
  307.   you for the text string you wish to search for (the word under the cursor
  308.   is your default response), and then prompt you with what you wish the word
  309.   to be changed to. Then FOLDED prompts you for the nature of the search and
  310.   replace logic to use. Your choices are:
  311.  
  312.   Option (A-all, U-up, D-down, E-exact, <ESC>) [once]:
  313.  
  314.   If you select 'A', then all occurrences of the string are searched for and
  315.   the substitution is made. If you press 'U' then replacements are made
  316.   from the current position and on up in the buffer. If you press 'D', then
  317.   the replacements work downward in the buffer. If you press the 'E' key,
  318.   the replacements are by exact word match only. Finally, if you just press
  319.   the return key, then only the first match is changed (i.e. this is a quick
  320.   'change word' command).
  321.  
  322.   Note that if you define a 'blok'ed region of text and happen to have your
  323.   cursor inside that region when you do a substitution, you will be prompted
  324.   as to whether you want your substitutions restricted just to that region
  325.   of text. Also, keep in mind that folded away text is NOT affected by a
  326.   global substitute. If you need to do a global substitute that looks inside
  327.   folds, press the '^f' (unfoldall) key first.
  328.  
  329. 6.10 DELETING:
  330.   To delete the character under the cursor, simply press the 'd' key. To delete
  331.   the whole line you are on, press the 'D' key. If you wish to do global
  332.   deletes of lines that contain or don't contain a particular string or word,
  333.   press the '-d' or '-v' key sequences. The '-d' key sequence will delete
  334.   every line that matches your search criteria, while the '-v' sequence deletes
  335.   every line that does not contain it. Both sequences will prompt you for the
  336.   string and ask if you wish the string to be inclusive or an exact word
  337.   match.
  338.  
  339. 6.11 INSERTS:
  340.   Inserting text into a buffer is quite simple. Simply move your cursor to
  341.   where you wish to start inserting and press the 'i' key to start inserting
  342.   before the cursor. When you are done typing in text and wish to move to
  343.   another part of the file or use any of the editor commands, just press the
  344.   ESC key. Note that while you are insert mode, you will see the following
  345.   prompt in bold at the bottom of the screen:
  346.  
  347.     Insert mode (^p-toggle auto indent). <ESC> when done.
  348.  
  349.   so it is pretty hard to forget how to get out of insert mode. The '^p' key
  350.   sequence may be used to turn off the auto-indent mode. Currently, auto-indent
  351.   is always turned on by default (this will be handled via a configuration file
  352.   in future versions.
  353.  
  354.   Three other commands are available for inserting text. The 'a' key is just
  355.   like the 'i' key, except it starts inserting text after the current character
  356.   under the cursor.  The 'I' key will insert a line in front of the current
  357.   line, tab over so that the new line is indented to the same level as the
  358.   previous line, and then puts you into insert mode at that positions. The
  359.   'A' key does the same thing, but creates the line after the line that your
  360.   cursor is on.
  361.  
  362. 6.12 FOLDING:
  363.   Folding is a complex enough topic that it is further described in Appendix 1.
  364.   The following is simply a list of the current set of commands that involve
  365.   folding:
  366.      f-fold by indentation,
  367.      F-fold by logic,
  368.      bf-fold a defined block
  369.      ^f-toggle unfoldall,
  370.   NOTE: press f or F on a fold to unfold it
  371.  
  372. 6.13 RELATES:
  373.   Relations are also a complex topic. For further information, see Appendix 2.
  374.   The current set of commands are defined as follows:
  375.     Rsl-Relate Set Line
  376.     Rsw-Relate Set Word
  377.     Rgl-Relate Goto Line
  378.     Rgw-Relate Goto Word
  379.     Rkl-Relate Kill Line
  380.     Rkw-Relate Kill Word
  381.     Rp-Relate Pop
  382.  
  383. 6.14 MARKING:
  384.    Marks are a handy feature to get used to, since they let you move around
  385.    within and between buffers in a very efficient manner. FOLDED utilizes
  386.    a one character global mark concept. All mark commands are invoked by
  387.    first pressing the 'm' key. The user then sees the following prompt:
  388.  
  389.    mark-? (Set, Goto, Kill, Clear all, <ESC>)
  390.  
  391.    Answering 's' will prompt the user for a keypress and assign the current
  392.    location (line number, character position, buffer number, etc) to that
  393.    key. For example, typing 'msa' will assign the current location to the
  394.    'a' key. Answering 'g' will prompt the user for which tag to go to. For
  395.    example, to get to the location tagged with the 'a' key, you simply type
  396.    'mga' and you will be immediately moved to that location. Note that FOLDED
  397.    searches in the current buffer for the 'tag key' first and then scans
  398.    all buffers. If you answer the prompt with a 'k' FOLDED asks whether you
  399.    wish to kill the tag(s) associated with the current line or a specific
  400.    key (you either press the key or press return to select the current line).
  401.    So pressing 'mka' will remove the tag associated with the 'a' key. Finally,
  402.    select the 'c' option if you wish to remove all tags defined in the current
  403.    buffer.
  404.  
  405. 6.15 EXTRAS:
  406.   One of the most important commands you will need to remember is the 'Q' key.
  407.   Pressing this key will exit you from FOLDED. If you have any buffers that
  408.   have been modified, but haven't been written to a file yet, FOLDED will ask
  409.   you if you are sure you wish to exit. Note that on most systems, pressing
  410.   CTRL-C will accomplish the same effect as pressing 'Q', although the effect
  411.   will be immediate if the compiler/OS used doesn't support signals (CTRL-C
  412.   is normally trapped to vector you to the same routine that pressing 'Q'
  413.   does). Also, on BSD systems, pressing CTRL-Z will cleanly interrupt your
  414.   editing session and allow you to resume at a later time (via fg).
  415.  
  416.   If you wish to invoke a shell or run an external program from within FOLDED,
  417.   simply press the '!' key and either press return when prompted, to start up
  418.   a shell, or type in the command you wish to run.
  419.  
  420.   To execute an external macro on the currently 'blok'ed region of text,
  421.   press the 'x' key. Right now, this command is experimental and really should
  422.   be considered unimplemented. I am still toying with different ideas in the
  423.   definition and implementation of external macros. Note that having external
  424.   macros does not preclude having internal macros at some future date.
  425.  
  426. 6.16 KEY TRAINING:
  427.   Occasionally, you will realize that you have to do something really
  428.   fairly simple a number of times. The use of the 'trained key' concept in
  429.   FOLDED comes in useful here. To turn on key training, press the '[' key.
  430.   You will be informed that key training is now turned on and that you can
  431.   turn it off with the ']' key. Now do whatever sequence of commands you
  432.   need to do and press the ']' key. You will be informed that the 'e' key
  433.   has now been trained. Now, every time you press the 'e' key you will see
  434.   the exact same sequence of commands performed.
  435.  
  436.   Note: the training does not carry over between edit sessions, but it will
  437.   carry over as you switch between buffers (in fact, switching between buffers
  438.   may be part of what the key is supposed to do). Also keep in mind that
  439.   this can be a fairly dangerous command, so keep the complexity of what your
  440.   are trying to do down until you are comfortable with the feature.
  441.  
  442.  
  443. 7.0 BACKUP PROTECTION:
  444.  
  445.   If FOLDED detects a local directory called febackup, then backup copies of
  446.   anything you edit will be placed in that directory. A rename operation is
  447.   performed on the original file, so this means that only local partition files
  448.   will be backed up in this fashion. Backups only take place at the time you
  449.   save a file the first time during an edit session, so no unnecessary backups
  450.   are made.
  451.  
  452.  
  453. 8.0 FOLDED CONTROL FILES:
  454.  
  455.   If folded detects a local directory called foldinfo, then FOLDED will store
  456.   all its control files there rather than clutter your directory with them. A
  457.   control file is created only when the file being edited is saved and has some
  458.   folding or relations in it. The control file will be a file of the same name,
  459.   but with an 'f' inserted immediately after the final '.' in the name...so
  460.   'test.c' has a control file called 'test.fc' and 'junk' would have 'junk.f'.
  461.  
  462.  
  463. 9.0 ENVIRONMENT VARIABLES:
  464.  
  465.   Several Environment variables may be used if you wish to avoid some prompting
  466.   by FOLDED. They are:
  467.  
  468.     FE_ASCII   - Save control files in ASCII (easier to mail that way)
  469.     FE_BINARY  - Save control files in BINARY (a bit faster and more efficient).
  470.     FE_NOTABS  - Always write files without tabs (useful on the Apollos).
  471.     FE_TABS    - Always fully optimize the files when writing.
  472.     MGR_FONT   - Size of the font used under MGR for the windows.
  473.  
  474.  
  475. 10.0 Coding Style
  476.  
  477.   I expect to take some flak on my coding style. I wrote most of this editor
  478.   in evenings after LONG days of mostly Pascal code design at ETA, so I tended
  479.   to keep things fairly simple, brute forcing the code where necessary. Most of
  480.   the current code I wrote as throwaway test code and just haven't had time to
  481.   re-design the logic. I also didn't originally plan on releasing the sources
  482.   to this code, so it is set up in such a manner that I can go back to it a
  483.   year or two from now and immediately be able to pick up where I left off.
  484.   Unfortunately, this doesn't mean there is sufficient in-line documentation
  485.   for others to port by.
  486.  
  487.   After (if) I get gcc ported to my Symmetrics (or if I get a job working for
  488.   a company that has a good ANSI compliant C compiler), I'll try to get FOLDED
  489.   'up to' ANSI C standards.  I hopefully have put in sufficient IFDEF's to
  490.   help minimize the porting issues, but feel free to send in any extra ones
  491.   you find your type of system needs.
  492.  
  493.  
  494. 11.0 Obtaining Updates to FOLDED
  495.  
  496.   FOLDED is an evolving product. As such, I expect to make fairly frequent
  497.   updates and release new versions several times a year (probably more often
  498.   in the first year or so). If you have USENET access, then keep an eye on
  499.   the sources newsgroups for diffs and/or new versions. If you want the
  500.   next major release earlier than it trickles out to the net (i.e. a month
  501.   or so earlier than normal), then follow the procedure outlined below but
  502.   remember to specify which release you currently have. Of course, this
  503.   would require that you have access to a PC or ST (or a floppy drive on
  504.   your Unix system and the mdrive PD software).
  505.  
  506.   For those of you who received a binary only version of FOLDED (the PC
  507.   or Atari ST versions), the most recent version with sources can be obtained
  508.   by sending $20 to the address shown below. Please specify computer and media
  509.   type. I can create SSDD or DSDD 3.5" disks for the Atari ST and 360K 5.25"
  510.   disks or 720K 3.5" disks for the IBM PC. If you are outside the United
  511.   States, then please add $5.00 shipping and handling (I prefer to ship by
  512.   Air Mail). Ordering in this way will register you for a mailing notice of
  513.   the next subsequent 'major' update.
  514.  
  515.     Todd Burkey
  516.     3546 Pilgrim Lane
  517.     Plymouth, MN 55441
  518.  
  519.     Home Phone (eve/wkends): (612) 542-1027
  520.     BBS I can be reached at: (612) 560-9254
  521.     Usenet Address via UUCP: pwcs!stag!trb
  522.  
  523. 12.0 COPYRIGHT INFORMATION
  524.  
  525.   The following paragraph defines the basic copyright information for
  526.   FOLDED. It is included at the top of each of the source modules and
  527.   must NOT be changed or removed from this document without written
  528.   permission of the author.
  529.  
  530.   This file is part of the FOLDED sources. FOLDED is a folding editor and
  531.   is copyrighted 1989 by Todd Burkey, 3546 Pilgrim Lane, Plymouth, MN 55441.
  532.   The author gives you the right to further distribute FOLDED, as long as
  533.   1) this notice remains intact in the sources, 2) the sources are made
  534.   available to the end user, and 3) the editor isn't sold for a profit. The
  535.   author makes no representations or warranties of fitness of this program
  536.   for any purpose. As with any free program, you use it at your own risk.
  537.  
  538. Appendix 1: FOLDING
  539.  
  540.   Obviously, a fundamental concept in using FOLDED is that of folding.
  541.   Folding in a text editor is a mechanism that allows you to cause
  542.   sections of code or text be replaced by a single line of text. This
  543.   is useful for 'hiding' away clean and functional sections of code
  544.   while you work on and only see the parts that you are currently
  545.   debugging. It also proves useful for tucking away big comment blocks.
  546.  
  547.   Worried that folding will change your source code? Don't worry, the
  548.   act of folding doesn't affect the edited file at all...even when saved.
  549.   When you save a file that has folds in it, a separate control file
  550.   is also saved under your current directory. See the section in the
  551.   documentation titled 'CONTROL FILES' for more info on this.
  552.  
  553.   In FOLDED, I implemented three types of folding. In each case, a
  554.   segment of your file is reduced such that all you see is the first
  555.   line of the segment in reverse image (or bold, depending on your
  556.   standout terminal mode). First, is the simple 'fold a marked block'.
  557.   This allows you to mark any arbitrary region of text and fold it away.
  558.   For example, lets say we had started with the following text (the
  559.   numbers are just for reference in this documentation):
  560.  
  561.    1: main()
  562.    2: /* GID for main - Just a test case
  563.    3:     Author: Todd Burkey
  564.    4:     Date:     1/27/89
  565.    5:     DESC:     Methodology for a test case
  566.    6: */
  567.    7: {
  568.    8:    if(this==that) {
  569.    9:      do_something_that_works();
  570.   10:      }
  571.   11:    }
  572.  
  573.   By defining a region between lines 2 and 6 and then folding, what you
  574.   would see on the screen would be:
  575.  
  576.    1: main()
  577.    2: /* GID for main - Just a test case    <-pretend this line is bold
  578.    7: {
  579.    8:    if(this==that) {
  580.    9:      do_something_that_works();
  581.   10:      }
  582.   11:    }
  583.  
  584.   Another method of folding is that based on 'indent level'. The logic
  585.   behind indent level folding is simply to start with the line the user
  586.   is currently on, move down in the text until an indent occurs, and
  587.   then continue down until an undent occurs that is less than or equal
  588.   to the original lines 'indented' position. For example, if you
  589.   had been on line 8 in the above 'folded' text when the 'f' key was
  590.   pressed, you would see the following:
  591.  
  592.    1: main()
  593.    2: /* GID for main - Just a test case    <-pretend this line is bold
  594.    7: {
  595.    8:    if(this==that) {            <-pretend this line is bold
  596.   11:    }
  597.  
  598.   Unfortunately, most source code contains lots of things that tend to
  599.   break up the clean indentation levels, so I added a third folding
  600.   mechanism. This one is a little smarter in that it does a 'logical
  601.   fold'. A logical fold looks for logical block begin/end marks in the
  602.   code (the braces in C) and skips around comments, strings, etc. For
  603.   example, if you had pressed the 'F' key on line 1 in any of the above
  604.   steps, you would end up with:
  605.  
  606.     1: main()                <-pretend this line is bold
  607.  
  608.   In all cases, unfolding the text is performed by simply moving to the
  609.   folded line and pressing the 'f' or 'F' key.
  610.  
  611.   Folding isn't all that novel a concept. It has been used for years now
  612.   in thought processor programs on the Mac, IBM PC, and even back in the
  613.   CP/M days. Thought processors usually use the 'fold by indent level'
  614.   technique. Take the following simple example:
  615.  
  616.   FOLDED Information
  617.     * specifications    <-pretend this line is bold
  618.     * plans        <-pretend this line is bold
  619.     * problems        <-pretend this line is bold
  620.  
  621.   This is all I see when I use FOLDED to call up my folded.info file.
  622.   Now, if I move to line 3 and press the f key, I will see:
  623.  
  624.   FOLDED Information
  625.     * specifications    <-pretend this line is bold
  626.     * plans
  627.       - Documentation    <-pretend this line is bold
  628.       - Enhancements    <-pretend this line is bold
  629.       - Bullet-proofing <-pretend this line is bold
  630.     * problems        <-pretend this line is bold
  631.  
  632.   In summary, folding is fully hierarchical (i.e. a fold can contain any number
  633.   of folds), it is smart (it can fold based on programming logic blocks and
  634.   indentation level), and it is retained from one edit session to the next.
  635.   The actual commands (and their associated key bindings) that involve folding
  636.   are:
  637.  
  638.     indent fold (f) : fold based on indent level logic
  639.     smart  fold (F) : fold based on {} logic
  640.     unfold (f or F) : unfold the fold under the cursor
  641.     temp unfold (^f): temporarily unfold all folds (for searching/sub'ing)
  642.     re-fold all (^f): yep, CTRL-f is just a toggle
  643.     block fold    (bf): fold current block region
  644.  
  645.  
  646. Appendix 2: RELATING
  647.  
  648.   The word 'relations' in the field of databases conjures up images of opening
  649.   up a large database, finding a particular entry, moving to a particular
  650.   field, and, with several keystrokes, calling up not only another database,
  651.   but a specific record in that database. Now, I have never understood why
  652.   we couldn't have similar capabilities in a text editor. We can envision
  653.   having a document file, moving to a specific part of the document, calling
  654.   up the source code file related to that part of the document, and then
  655.   moving to the appropriate spot in the source file. We can even imagine
  656.   moving through the source code and finding a structure (or variable) and
  657.   wishing we could immediately view the definition of the structure. These
  658.   scenarios are fundamentally the same as those handled by a relational
  659.   database program.
  660.  
  661.   Relationships as pertains to editors (and, of course, in this context, FOLDED)
  662.   primarily involve two concepts.  First, there are word relationships.  These
  663.   are something like 'glossary' entries in that you define a word once in a file
  664.   and then can immediately go to the exact place you defined it from anywhere in
  665.   the file (or any other file you are currently editing.) From a programming
  666.   viewpoint, this simply means that you can move your cursor over a structure
  667.   name in a source file and with a few keystrokes be placed immediately in an
  668.   include file at the place the structure is defined.  A second relationship type
  669.   is that of line relations.  These are basically invisible links that relate a
  670.   line in one buffer to a line in another buffer.  This type of relationship
  671.   allows you to easily move back and forth between source code and program
  672.   outlines/documents.  Folded will even open up a file if you try to go to a
  673.   relation in a file that you aren't currently editing.
  674.  
  675.   FOLDED supports a number of commands that allow easy creation and use of
  676.   these relationships. The following key sequences are used to perform the
  677.   most common relation operations:
  678.  
  679.    Rsl (Relate Set Line): The current line becomes 1/2 of a line relationship.
  680.               The next Rs command will complete the relationship.
  681.    Rsw (Relate Set Word): The current word is indexed for reference.
  682.    Rgl (Relate Goto Line):FOLDED looks at the first line with a relation on or
  683.               above the current line and goes to its related line.
  684.               If the related line is in a file not currently being
  685.               edited it will be opened for viewing.
  686.    Rgw (Relate Goto Word):Read the word under the cursor and move to the correct
  687.               file that it was defined in.
  688.    Rkl (Relate Kill Line):Kill the relationship for the current line.
  689.    Rkw (Relate Kill Word):Kill the relationship for the current word.
  690.    Rp  (Relate Pop):      Pop back to where you were before the last Relate Goto.
  691.               The pop stack is currently 10 levels deep.
  692.  
  693.   As with folding, the relationship information does not affect the actual
  694.   files you are editing. In fact, the information is simply saved out as part
  695.   of the folding info files. It is also important to note that neither folding
  696.   or relations affect the speed of loading, saving, or using the various editor
  697.   features to a notable extent.
  698.  
  699.   Since I added relations very late in the development of the editor, I have a
  700.   feeling that this area will see the most improvement over the next year. I've
  701.   already decided that I need a few more commands to do things like 'move'
  702.   and 'view' relationships.
  703.  
  704. Appendix 3: IMPLEMENTATION DETAILS
  705.  
  706.   Folded uses a doubly linked list to store lines internally. It mallocs
  707.   the exact amount of memory a line needs on read-in, but as you modify lines
  708.   it will malloc additional memory in 4 byte chunks...so you can end up with
  709.   some wastage if you edit a lot of lines in a file. FOLDED keeps track of a
  710.   lot of information about lines in the buffers, so there is quite a bit of
  711.   overhead in using FOLDED. I place it pretty close to emacs in the amount
  712.   of overhead required for 'data' storage, but since the executable is only
  713.   about 60K it wipes emacs away in raw loading time (program+files). I haven't
  714.   had time to optimize the code for speed yet, but things like searching and
  715.   substituting are significantly faster than emacs and slightly faster than
  716.   vi. This is partly due to the design of the editor and also may be due to
  717.   FOLDED's lack of regular expression parsing routines.
  718.  
  719.   The first version of FOLDED isn't as optimized as it could be in the sense
  720.   that ints may be used where chars may get by. Also, there may be tricks I
  721.   don't know about that could compress the amount of overhead I incur in the
  722.   storage of lines, buffers, etc.
  723.  
  724.